//
//  CellForWHTStoryFourModel.m
//  WZLProduct
//
//  Created by dllo on 16/3/28.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "CellForWHTStoryFourModel.h"
#import "WHTStoryFourModelCollectionCell.h"
@interface CellForWHTStoryFourModel ()<UICollectionViewDataSource,UICollectionViewDelegate>
@end
@implementation CellForWHTStoryFourModel
static NSString *WHTStoryFourModelCollectionCell_id = @"WHTStoryFourModelCollectionCell_id";


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor grayColor];
        
        self.loveCount = [[UILabel alloc] init];
        [self.contentView addSubview:self.loveCount];
        self.loveCount.text = @"00 人喜欢";
        self.loveCount.textColor = [UIColor lightTextColor];
        
        //集合视图
        [self initCollectionView];
        
        self.comments = [[UILabel alloc] init];
        [self.contentView addSubview:self.comments];
        self.comments.text = @"00 人评论";
        self.comments.textColor = [UIColor lightTextColor];
        
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.loveCount.frame = CGRectMake(10, 15, kScreenWidth - 20, 25);
    self.collectionView.frame = CGRectMake(10, CGRectGetMaxY(self.loveCount.frame), kScreenWidth - 20, (kScreenWidth - 100) / 9);
    self.comments.frame = CGRectMake(10, self.contentView.bounds.size.height - 25, kScreenWidth - 20, 25);
    
}

#pragma mark- 创建集合视图
- (void)initCollectionView{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.itemSize = CGSizeMake((kScreenWidth - 100) / 9, (kScreenWidth - 100) / 9);
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.loveCount.frame), kScreenWidth - 20, (kScreenWidth - 100) / 9) collectionViewLayout:layout];
    
    self.collectionView.backgroundColor = [UIColor clearColor];
    [self addSubview:self.collectionView];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    
    //注册cell
    [self.collectionView registerClass:[WHTStoryFourModelCollectionCell class] forCellWithReuseIdentifier:WHTStoryFourModelCollectionCell_id];

    
}
/** item个数 */
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return 10;
}
/** cellForItem */
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    WHTStoryFourModelCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:WHTStoryFourModelCollectionCell_id forIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor redColor];
    return cell;
}
/** 点击事件 */
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    
}

@end
